package com.tangkun.environment.activity;

import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.support.annotation.IdRes;
import android.text.TextUtils;
import android.view.View;
import android.widget.EditText;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.RadioButton;
import android.widget.RadioGroup;
import android.widget.TextView;

import com.bumptech.glide.Glide;
import com.squareup.okhttp.MediaType;
import com.squareup.okhttp.RequestBody;
import com.tangkun.environment.R;
import com.tangkun.environment.adapter.ImageFileNoAddAdapter;
import com.tangkun.environment.entity.base.CommonReturn;
import com.tangkun.environment.entity.gongzuo.CategoryTreeDataReturn;
import com.tangkun.environment.entity.gongzuo.EnterpriseDetailReturn;
import com.tangkun.environment.entity.personcenter.UploadResourceReturn;
import com.tangkun.environment.entity.xinwen.TypeReturn;
import com.tangkun.environment.network.MySubscribe;
import com.tangkun.environment.rx.RxActivityHelper;
import com.tangkun.environment.utils.JumpHelper;
import com.tangkun.environment.utils.LogUtils;
import com.tangkun.environment.utils.Utils;
import com.tangkun.environment.view.CircleImageView;
import com.tangkun.environment.view.MyGridView;

import org.simple.eventbus.EventBus;

import java.io.File;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;
import cn.qqtheme.framework.picker.DatePicker;
import jp.wasabeef.glide.transformations.CropCircleTransformation;

/**
 * 关联企业
 */
public class GuanLianQiYeActivity extends BaseActivity {

    @BindView(R.id.back)
    ImageView back;
    @BindView(R.id.title)
    TextView title;
    @BindView(R.id.next)
    TextView next;
    @BindView(R.id.iv_more_qiye)
    ImageView ivMoreQiye;
    @BindView(R.id.et_faren_qiyemingcheng)
    EditText etFarenQiyemingcheng;
    @BindView(R.id.ll_qiye_qiyeleixing)
    LinearLayout llQiyeQiyeleixing;
    @BindView(R.id.tv_qiye_qiyeleixing)
    TextView tvQiyeQiyeleixing;
    @BindView(R.id.et_qiye_yingyezhizhaohaoma)
    EditText etQiyeYingyezhizhaohaoma;
    @BindView(R.id.tv_qiye_jiansheshijian)
    TextView tvQiyeJiansheshijian;
    @BindView(R.id.ll_qiye_jiansheshijian)
    LinearLayout llQiyeJiansheshijian;
    @BindView(R.id.tv_qiye_kaiyeshiijian)
    TextView tvQiyeKaiyeshiijian;
    @BindView(R.id.ll_qiye_kaiyeshiijian)
    LinearLayout llQiyeKaiyeshiijian;
    @BindView(R.id.tv_qiye_xiangxidizhi)
    TextView tvQiyeXiangxidizhi;
    @BindView(R.id.ll_qiye_xiangxidizhi)
    LinearLayout llQiyeXiangxidizhi;
    @BindView(R.id.tv_qiye_yingyezhizhao)
    TextView tvQiyeYingyezhizhao;
    @BindView(R.id.mygridview_yingyezhizhao)
    MyGridView mygridviewYingyezhizhao;
    @BindView(R.id.ll_qiye_yingyezhizhao)
    LinearLayout llQiyeYingyezhizhao;
    @BindView(R.id.tv_qiye_yingyezhizhao_youxiaoqizhi)
    TextView tvQiyeYingyezhizhaoYouxiaoqizhi;
    @BindView(R.id.ll_qiye_yingyezhizhao_youxiaoqizhi)
    LinearLayout llQiyeYingyezhizhaoYouxiaoqizhi;
    @BindView(R.id.tv_qiye_fangchanzheng)
    TextView tvQiyeFangchanzheng;
    @BindView(R.id.mygridview_fangchanzheng)
    MyGridView mygridviewFangchanzheng;
    @BindView(R.id.ll_qiye_fangchanzheng)
    LinearLayout llQiyeFangchanzheng;
    @BindView(R.id.tv_qiye_fangchanzheng_youxiaoqizhi)
    TextView tvQiyeFangchanzhengYouxiaoqizhi;
    @BindView(R.id.ll_qiye_fangchanzheng_youxiaoqizhi)
    LinearLayout llQiyeFangchanzhengYouxiaoqizhi;
    @BindView(R.id.ll_more_qiye)
    LinearLayout llMoreQiye;
    @BindView(R.id.iv_more_faren)
    ImageView ivMoreFaren;
    @BindView(R.id.et_faren_farenxingming)
    EditText etFarenFarenxingming;
    @BindView(R.id.et_faren_lianxifangshi)
    EditText etFarenLianxifangshi;
    @BindView(R.id.tv_faren_shenfenzheng)
    TextView tvFarenShenfenzheng;
    @BindView(R.id.mygridview_fanrenshenfenzheng)
    MyGridView mygridviewFanrenshenfenzheng;
    @BindView(R.id.ll_faren_shenfenzheng)
    LinearLayout llFarenShenfenzheng;
    @BindView(R.id.tv_faren_shenfenzheng_youxiaoqizhi)
    TextView tvFarenShenfenzhengYouxiaoqizhi;
    @BindView(R.id.ll_faren_shenfenzheng_youxiaoqizhi)
    LinearLayout llFarenShenfenzhengYouxiaoqizhi;
    @BindView(R.id.ll_more_faren)
    LinearLayout llMoreFaren;
    @BindView(R.id.iv_more_faren_huanbaofuzeren)
    ImageView ivMoreFarenHuanbaofuzeren;
    @BindView(R.id.et_fuzeren_fuzerenxingming)
    EditText etFuzerenFuzerenxingming;
    @BindView(R.id.et_fuzeren_lianxifangshi)
    EditText etFuzerenLianxifangshi;
    @BindView(R.id.ll_more_huanbaofuzeren)
    LinearLayout llMoreHuanbaofuzeren;
    @BindView(R.id.iv_more_hangyexinxi)
    ImageView ivMoreHangyexinxi;
    @BindView(R.id.ll_hangyexinxi_hangyefenlei)
    LinearLayout llHangyexinxiHangyefenlei;
    @BindView(R.id.tv_hangyexinxi_hangyefenlei)
    TextView tvHangyexinxiHangyefenlei;
    @BindView(R.id.et_hangyexinxi_hangyeguimo)
    EditText etHangyexinxiHangyeguimo;
    @BindView(R.id.ll_more_hangyexinxi)
    LinearLayout llMoreHangyexinxi;
    @BindView(R.id.iv_more_huanjingzhaopian)
    ImageView ivMoreHuanjingzhaopian;
    @BindView(R.id.tv_huanjingzhaopian_tianjiahuanjingzhaopian)
    TextView tvHuanjingzhaopianTianjiahuanjingzhaopian;
    @BindView(R.id.mygridview_tianjiahuanjingzhaopian)
    MyGridView mygridviewTianjiahuanjingzhaopian;
    @BindView(R.id.ll_huanjingzhaopian_tianjiahuanjingzhaopian)
    LinearLayout llHuanjingzhaopianTianjiahuanjingzhaopian;
    @BindView(R.id.ll_more_huanjingzhaopian)
    LinearLayout llMoreHuanjingzhaopian;
    @BindView(R.id.ll_qiye)
    LinearLayout llQiye;
    @BindView(R.id.rb_faren_ishuanbaofuzeren_yes)
    RadioButton rbFarenIshuanbaofuzerenYes;
    @BindView(R.id.rb_faren_ishuanbaofuzeren_no)
    RadioButton rbFarenIshuanbaofuzerenNo;
    @BindView(R.id.rg_faren_ishuanbaofuzeren)
    RadioGroup rgFarenIshuanbaofuzeren;
    @BindView(R.id.ll_faren)
    LinearLayout llFaren;
    @BindView(R.id.ll_huanbaofuzeren)
    LinearLayout llHuanbaofuzeren;
    @BindView(R.id.ll_huanbaoxinxi)
    LinearLayout llHuanbaoxinxi;
    @BindView(R.id.ll_huanjingzhaopian)
    LinearLayout llHuanjingzhaopian;
    @BindView(R.id.iv_qiye_shangchuandianzhao)
    CircleImageView ivQiyeShangchuandianzhao;

    private Context mContext;

    /**
     * 日期选择器
     */
    private DatePicker datePicker;
    /**
     * 图片列表适配器 营业执照
     */
    private ImageFileNoAddAdapter adapterYingyezhizhao;
    /**
     * 图片列表适配器 房产证
     */
    private ImageFileNoAddAdapter adapterFangchanzheng;
    /**
     * 图片列表适配器 法人身份证
     */
    private ImageFileNoAddAdapter adapterFarenshenfenzheng;
    /**
     * 图片列表适配器 环境照片
     */
    private ImageFileNoAddAdapter adapterHuanjingzhaopian;
    /**
     * 最大图片上传张数 上传店招
     */
    private static final int IMAGE_NUM_SHANGCHUANDIANZHAO = 1;
    /**
     * 最大图片上传张数 营业执照
     */
    private static final int IMAGE_NUM_YINGYEZHIZHAO = 2;
    /**
     * 最大图片上传张数 房产证
     */
    private static final int IMAGE_NUM_FANGCHANZHENG = 2;
    /**
     * 最大图片上传张数 法人身份证
     */
    private static final int IMAGE_NUM_FARENSHENFENZHENG = 2;
    /**
     * 最大图片上传张数 环境照片
     */
    private static final int IMAGE_NUM_HUANJINGZHAOPIAN = 9;
    private static final int IMAGE_W = 400;
    private static final int IMAGE_H = 200;
    private static final int CAPTURE_IMAGE = 1;
    public static final int REQUEST_CODE_SHANGCHUANDIANZHAO = 1;// 请求码 上传店招
    private final int REQUEST_CODE_YINGYEZHIZHAO = 2;// 请求码 营业执照
    private final int REQUEST_CODE_FANGCHANZHENG = 3;// 请求码 房产证
    private final int REQUEST_CODE_FARENSHENFENZHENG = 4;// 请求码 法人身份证
    private final int REQUEST_CODE_HUANJINGZHAOPIAN = 5;// 请求码 环境照片

    private final int REQUEST_CODE_QIYELEIXING = 7;// 请求码 企业类型
    private final int REQUEST_CODE_XIANGXIDIZHI = 8;// 请求码 详细地址
    private final int REQUEST_CODE_HANGYEFENLEI = 9;// 请求码 行业分类

    /**
     * 完成上传图片 上传店招
     */
    private boolean uploadImgShangchuandianzhao = false;
    /**
     * 完成上传图片 营业执照
     */
    private boolean uploadImgYingyezhizhao = false;
    /**
     * 完成上传图片 房产证
     */
    private boolean uploadImgFangchanzheng = false;
    /**
     * 完成上传图片 法人身份证
     */
    private boolean uploadImgFarenshenfenzheng = false;
    /**
     * 完成上传图片 环境照片
     */
    private boolean uploadImgHuanjingzhaopian = false;

    /**
     * 已上传的图片，逗号拼接 上传店招
     */
    private String imgShangchuandianzhao = "";
    /**
     * 已上传的图片，逗号拼接 营业执照
     */
    private String imgYingyezhizhao = "";
    /**
     * 已上传的图片，逗号拼接 房产证
     */
    private String imgFangchanzheng = "";
    /**
     * 已上传的图片，逗号拼接 法人身份证
     */
    private String imgFarenshenfenzheng = "";
    /**
     * 已上传的图片，逗号拼接 环境照片
     */
    private String imgHuanjingzhaopian = "";

    /**
     * 对象集合，上传的时候就在这个对象里取参数，从服务器下发的参数里赋值
     */
    private EnterpriseDetailReturn.DataBean dataBean = new EnterpriseDetailReturn.DataBean();
    /**
     * 本地图片 上传店招
     */
    private List<File> fileListShangchuandianzhao = new ArrayList<File>();
    /**
     * 详细地址 经纬度
     */
    private String latitude = "";
    /**
     * 详细地址 经纬度
     */
    private String longitude = "";
    /**
     * 详细地址
     */
    private String address = "";

    /**
     * 数据源 企业类型
     */
    private List<TypeReturn.DataBean> dataListEpType = new ArrayList<TypeReturn.DataBean>();
    /**
     * 数据源 行业分类
     */
    private List<CategoryTreeDataReturn.DataBean> dataListCategoryTreeData = new ArrayList<CategoryTreeDataReturn.DataBean>();

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_guanlianqiye);
        mContext = this;
        ButterKnife.bind(this);
        title.setText("关联企业");
        next.setText("提交审核");

        initData();
        initListener();
        //请求企业类型
        queryType("ep-type");
        //请求行业分类
        categoryTreeData();
    }

    private void initData() {
        //营业执照
        adapterYingyezhizhao = new ImageFileNoAddAdapter(this, R.layout.weibo_pic_list);
        adapterYingyezhizhao.setCanDelete(true);
        adapterYingyezhizhao.setREQUEST_CODE(REQUEST_CODE_YINGYEZHIZHAO);
        adapterYingyezhizhao.getFileList();// initialize fileList
        Utils.setGridViewHeightBasedOnChildren(mygridviewYingyezhizhao, 7);
        mygridviewYingyezhizhao.setAdapter(adapterYingyezhizhao);

        //房产证
        adapterFangchanzheng = new ImageFileNoAddAdapter(this, R.layout.weibo_pic_list);
        adapterFangchanzheng.setCanDelete(true);
        adapterFangchanzheng.setREQUEST_CODE(REQUEST_CODE_FANGCHANZHENG);
        adapterFangchanzheng.getFileList();// initialize fileList
        Utils.setGridViewHeightBasedOnChildren(mygridviewFangchanzheng, 7);
        mygridviewFangchanzheng.setAdapter(adapterFangchanzheng);

        //法人身份证
        adapterFarenshenfenzheng = new ImageFileNoAddAdapter(this, R.layout.weibo_pic_list);
        adapterFarenshenfenzheng.setCanDelete(true);
        adapterFarenshenfenzheng.setREQUEST_CODE(REQUEST_CODE_FARENSHENFENZHENG);
        adapterFarenshenfenzheng.getFileList();// initialize fileList
        Utils.setGridViewHeightBasedOnChildren(mygridviewFanrenshenfenzheng, 7);
        mygridviewFanrenshenfenzheng.setAdapter(adapterFarenshenfenzheng);

        //环境照片
        adapterHuanjingzhaopian = new ImageFileNoAddAdapter(this, R.layout.weibo_pic_list);
        adapterHuanjingzhaopian.setCanDelete(true);
        adapterHuanjingzhaopian.setREQUEST_CODE(REQUEST_CODE_HUANJINGZHAOPIAN);
        adapterHuanjingzhaopian.getFileList();// initialize fileList
        Utils.setGridViewHeightBasedOnChildren(mygridviewTianjiahuanjingzhaopian, 7);
        mygridviewTianjiahuanjingzhaopian.setAdapter(adapterHuanjingzhaopian);
    }

    private void initListener() {
        //是否为环保负责人radiobutton监听
        rgFarenIshuanbaofuzeren.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener() {
            @Override
            public void onCheckedChanged(RadioGroup radioGroup, @IdRes int i) {
                switch (i) {
                    case R.id.rb_faren_ishuanbaofuzeren_yes://是环保负责人
                        dataBean.legalismaster = "1";//1表示环保负责人
                        llHuanbaofuzeren.setVisibility(View.GONE);
                        break;
                    case R.id.rb_faren_ishuanbaofuzeren_no://不是环保负责人
                        dataBean.legalismaster = "0";//1表示不是环保负责人
                        llHuanbaofuzeren.setVisibility(View.VISIBLE);
                        break;
                }
            }
        });
    }

    @OnClick({R.id.back, R.id.next, R.id.iv_more_qiye, R.id.ll_qiye_qiyeleixing, R.id.iv_qiye_shangchuandianzhao, R.id.tv_qiye_jiansheshijian, R.id.ll_qiye_jiansheshijian, R.id.tv_qiye_kaiyeshiijian, R.id.ll_qiye_kaiyeshiijian, R.id.tv_qiye_xiangxidizhi, R.id.ll_qiye_xiangxidizhi, R.id.tv_qiye_yingyezhizhao, R.id.ll_qiye_yingyezhizhao, R.id.tv_qiye_yingyezhizhao_youxiaoqizhi, R.id.ll_qiye_yingyezhizhao_youxiaoqizhi, R.id.tv_qiye_fangchanzheng, R.id.ll_qiye_fangchanzheng, R.id.tv_qiye_fangchanzheng_youxiaoqizhi, R.id.ll_qiye_fangchanzheng_youxiaoqizhi, R.id.ll_more_qiye, R.id.iv_more_faren, R.id.tv_faren_shenfenzheng, R.id.ll_faren_shenfenzheng, R.id.tv_faren_shenfenzheng_youxiaoqizhi, R.id.ll_faren_shenfenzheng_youxiaoqizhi, R.id.ll_more_faren, R.id.iv_more_faren_huanbaofuzeren, R.id.ll_more_huanbaofuzeren, R.id.iv_more_hangyexinxi, R.id.ll_hangyexinxi_hangyefenlei, R.id.ll_more_hangyexinxi, R.id.iv_more_huanjingzhaopian, R.id.tv_huanjingzhaopian_tianjiahuanjingzhaopian, R.id.ll_huanjingzhaopian_tianjiahuanjingzhaopian, R.id.ll_more_huanjingzhaopian})
    public void onClick(View view) {
        switch (view.getId()) {
            case R.id.back:
                Utils.hideSoftKeyboard(GuanLianQiYeActivity.this, back);
                JumpHelper.finish(mContext);
                break;
            case R.id.next:
                judgeEmpty();
                break;
            case R.id.iv_more_qiye://企业更多
                if (llMoreQiye.getVisibility() == View.VISIBLE) {
                    llMoreQiye.setVisibility(View.GONE);
                    ivMoreQiye.setImageResource(R.mipmap.ic_down);
                } else {
                    llMoreQiye.setVisibility(View.VISIBLE);
                    ivMoreQiye.setImageResource(R.mipmap.ic_up);
                }
                break;
            case R.id.iv_qiye_shangchuandianzhao://上传店招
                openXiangceShangchuandianzhao();
                break;
            case R.id.ll_qiye_qiyeleixing://企业类型
                Intent qiyeleixingIntent = new Intent(GuanLianQiYeActivity.this, QiYeLeiXingActivity.class);
                qiyeleixingIntent.putExtra("selectedIds", dataBean.type);//选中ID
                qiyeleixingIntent.putExtra("data", (Serializable) dataListEpType);//数据源
                JumpHelper.jumpForResult(GuanLianQiYeActivity.this, qiyeleixingIntent, REQUEST_CODE_QIYELEIXING, false);
                break;
            case R.id.tv_qiye_jiansheshijian://建设时间
                setDate(tvQiyeJiansheshijian);
                dataBean.buildtime = tvQiyeJiansheshijian.getText().toString();
                break;
            case R.id.ll_qiye_jiansheshijian://建设时间
                setDate(tvQiyeJiansheshijian);
                dataBean.buildtime = tvQiyeJiansheshijian.getText().toString();
                break;
            case R.id.tv_qiye_kaiyeshiijian://开业时间
                setDate(tvQiyeKaiyeshiijian);
                dataBean.opentime = tvQiyeKaiyeshiijian.getText().toString();
                break;
            case R.id.ll_qiye_kaiyeshiijian://开业时间
                setDate(tvQiyeKaiyeshiijian);
                dataBean.opentime = tvQiyeKaiyeshiijian.getText().toString();
                break;
            case R.id.tv_qiye_xiangxidizhi://详细地址
                Intent xiangxidizhiIntent = new Intent(GuanLianQiYeActivity.this, LocationDemo3.class);
                JumpHelper.jumpForResult(GuanLianQiYeActivity.this, xiangxidizhiIntent, REQUEST_CODE_XIANGXIDIZHI, false);
                break;
            case R.id.ll_qiye_xiangxidizhi://详细地址
                break;
            case R.id.tv_qiye_yingyezhizhao://营业执照／灵活就业辅助证
                openXiangceYingyezhizhao();
                break;
            case R.id.ll_qiye_yingyezhizhao://营业执照／灵活就业辅助证
                break;
            case R.id.tv_qiye_yingyezhizhao_youxiaoqizhi://营业执照／灵活就业辅助证 有效期至
                setDate(tvQiyeYingyezhizhaoYouxiaoqizhi);
                dataBean.licensetime = tvQiyeYingyezhizhaoYouxiaoqizhi.getText().toString();
                break;
            case R.id.ll_qiye_yingyezhizhao_youxiaoqizhi://营业执照／灵活就业辅助证 有效期至
                setDate(tvQiyeYingyezhizhaoYouxiaoqizhi);
                dataBean.licensetime = tvQiyeYingyezhizhaoYouxiaoqizhi.getText().toString();
                break;
            case R.id.tv_qiye_fangchanzheng://房租租赁合同／房产证
                openXiangceFangchanzheng();
                break;
            case R.id.ll_qiye_fangchanzheng://房租租赁合同／房产证
                break;
            case R.id.tv_qiye_fangchanzheng_youxiaoqizhi://房租租赁合同／房产证 有效期至
                setDate(tvQiyeFangchanzhengYouxiaoqizhi);
                dataBean.fangchantime = tvQiyeFangchanzhengYouxiaoqizhi.getText().toString();
                break;
            case R.id.ll_qiye_fangchanzheng_youxiaoqizhi://房租租赁合同／房产证 有效期至
                setDate(tvQiyeFangchanzhengYouxiaoqizhi);
                dataBean.fangchantime = tvQiyeFangchanzhengYouxiaoqizhi.getText().toString();
                break;
            case R.id.ll_more_qiye://企业更多
                break;
            case R.id.iv_more_faren://法人更多
                if (llMoreFaren.getVisibility() == View.VISIBLE) {
                    llMoreFaren.setVisibility(View.GONE);
                    ivMoreFaren.setImageResource(R.mipmap.ic_down);
                } else {
                    llMoreFaren.setVisibility(View.VISIBLE);
                    ivMoreFaren.setImageResource(R.mipmap.ic_up);
                }
                break;
            case R.id.tv_faren_shenfenzheng://法人身份证（正反面）
                openXiangceFarenshenfenzheng();
                break;
            case R.id.ll_faren_shenfenzheng://法人身份证（正反面）
                break;
            case R.id.tv_faren_shenfenzheng_youxiaoqizhi://法人身份证（正反面）有效期至
                setDate(tvFarenShenfenzhengYouxiaoqizhi);
                dataBean.legalcardtime = tvFarenShenfenzhengYouxiaoqizhi.getText().toString();
                break;
            case R.id.ll_faren_shenfenzheng_youxiaoqizhi://法人身份证（正反面）有效期至
                setDate(tvFarenShenfenzhengYouxiaoqizhi);
                dataBean.legalcardtime = tvFarenShenfenzhengYouxiaoqizhi.getText().toString();
                break;
            case R.id.ll_more_faren://法人更多
                break;
            case R.id.iv_more_faren_huanbaofuzeren://环保负责人更多
                if (llMoreHuanbaofuzeren.getVisibility() == View.VISIBLE) {
                    llMoreHuanbaofuzeren.setVisibility(View.GONE);
                    ivMoreFarenHuanbaofuzeren.setImageResource(R.mipmap.ic_down);
                } else {
                    llMoreHuanbaofuzeren.setVisibility(View.VISIBLE);
                    ivMoreFarenHuanbaofuzeren.setImageResource(R.mipmap.ic_up);
                }
                break;
            case R.id.ll_more_huanbaofuzeren://环境负责人更多
                break;
            case R.id.iv_more_hangyexinxi://行业信息更多
                if (llMoreHangyexinxi.getVisibility() == View.VISIBLE) {
                    llMoreHangyexinxi.setVisibility(View.GONE);
                    ivMoreHangyexinxi.setImageResource(R.mipmap.ic_down);
                } else {
                    llMoreHangyexinxi.setVisibility(View.VISIBLE);
                    ivMoreHangyexinxi.setImageResource(R.mipmap.ic_up);
                }
                break;
            case R.id.ll_hangyexinxi_hangyefenlei://行业信息 行业分类
                Intent hangyefenleiIntent = new Intent(GuanLianQiYeActivity.this, HangYeFenLeiActivity.class);
                hangyefenleiIntent.putExtra("data", (Serializable) dataListCategoryTreeData);//行业分类数据源
                JumpHelper.jumpForResult(GuanLianQiYeActivity.this, hangyefenleiIntent, REQUEST_CODE_HANGYEFENLEI, false);
                break;
            case R.id.ll_more_hangyexinxi://行业信息更多
                break;
            case R.id.iv_more_huanjingzhaopian://环境照片更多
                if (llMoreHuanjingzhaopian.getVisibility() == View.VISIBLE) {
                    llMoreHuanjingzhaopian.setVisibility(View.GONE);
                    ivMoreHuanjingzhaopian.setImageResource(R.mipmap.ic_down);
                } else {
                    llMoreHuanjingzhaopian.setVisibility(View.VISIBLE);
                    ivMoreHuanjingzhaopian.setImageResource(R.mipmap.ic_up);
                }
                break;
            case R.id.tv_huanjingzhaopian_tianjiahuanjingzhaopian://添加环境照片
                openXiangceHuanjingzhaopian();
                break;
            case R.id.ll_huanjingzhaopian_tianjiahuanjingzhaopian://添加环境照片
                break;
            case R.id.ll_more_huanjingzhaopian://环境照片更多
                break;
        }
    }

    /**
     * 获取企业类型
     *
     * @param numbers 新闻类别：news-type；咨询分类：question-type 企业类型：ep-type
     */
    private void queryType(final String numbers) {
        fromNetwork.queryType(numbers).compose(new RxActivityHelper<TypeReturn>().ioMain(GuanLianQiYeActivity.this, false))
                .subscribe(new MySubscribe<TypeReturn>(GuanLianQiYeActivity.this, false) {
                    @Override
                    protected void success(TypeReturn resultBean) {
                        if (resultBean.data != null) {
                            dataListEpType.clear();
                            dataListEpType.addAll(resultBean.data);
                            for (TypeReturn.DataBean bean : dataListEpType) {
                                //根据ID检索企业类型
                                if (bean.numbers.equals(dataBean.type)) {
                                    //企业类型
                                    if (!TextUtils.isEmpty(bean.val)) {
                                        tvQiyeQiyeleixing.setText(bean.val);
                                    } else {
                                        tvQiyeQiyeleixing.setText("");
                                    }
                                }
                            }
                        }
                    }

                    @Override
                    protected void onMyError(String errorMessage) {
                        showToast(errorMessage + "");
                    }
                });
    }

    /**
     * 行业分类
     */
    private void categoryTreeData() {
        fromNetwork.categoryTreeData().compose(new RxActivityHelper<CategoryTreeDataReturn>().ioMain(GuanLianQiYeActivity.this, false))
                .subscribe(new MySubscribe<CategoryTreeDataReturn>(GuanLianQiYeActivity.this, false) {
                    @Override
                    protected void success(CategoryTreeDataReturn resultBean) {
                        if (resultBean.data != null) {
                            //添加数据
                            dataListCategoryTreeData.clear();
                            dataListCategoryTreeData.addAll(resultBean.data);
                            for (CategoryTreeDataReturn.DataBean bean : dataListCategoryTreeData) {
                                //根据ID检索行业分类
                                if (bean.id.equals(dataBean.categoryid)) {
                                    //行业分类
                                    if (!TextUtils.isEmpty(bean.name)) {
                                        tvQiyeQiyeleixing.setText(bean.name);
                                    } else {
                                        tvQiyeQiyeleixing.setText("");
                                    }
                                }
                            }
                        }
                    }

                    @Override
                    protected void onMyError(String errorMessage) {
                        showToast(errorMessage + "");
                    }
                });
    }

    /**
     * 判断图片是否都上传完成了 都上传完成后才调用绑定企业接口
     */
    private void judgeEmpty() {
        //待上传图片 上传店招
        if (!uploadImgShangchuandianzhao) {
            if (fileListShangchuandianzhao == null || fileListShangchuandianzhao.size() <= 0) {
                uploadImgShangchuandianzhao = true;
            } else {
                sendPhotoToServerShangchuanDianzhao((fileListShangchuandianzhao.get(0)).getPath());
            }
        }
        //待上传图片 营业执照
        if (!uploadImgYingyezhizhao) {
            if (adapterYingyezhizhao.getFileList() == null || adapterYingyezhizhao.getFileList().size() <= 0) {
                uploadImgYingyezhizhao = true;
            } else {
                for (File file : adapterYingyezhizhao.getFileList()) {
                    sendPhotoToServerYingyezhizhao(file.getPath());
                }
            }
        }
        //待上传图片 房产证
        if (!uploadImgFangchanzheng) {
            if (adapterFangchanzheng.getFileList() == null || adapterFangchanzheng.getFileList().size() <= 0) {
                uploadImgFangchanzheng = true;
            } else {
                for (File file : adapterFangchanzheng.getFileList()) {
                    sendPhotoToServerFangChanZheng(file.getPath());
                }
            }
        }
        //待上传图片 法人身份证
        if (!uploadImgFarenshenfenzheng) {
            if (adapterFarenshenfenzheng.getFileList() == null || adapterFarenshenfenzheng.getFileList().size() <= 0) {
                uploadImgFarenshenfenzheng = true;
            } else {
                for (File file : adapterFarenshenfenzheng.getFileList()) {
                    sendPhotoToServerFarenshenfenzheng(file.getPath());
                }
            }
        }
        //待上传图片 环境照片
        if (!uploadImgHuanjingzhaopian) {
            if (adapterHuanjingzhaopian.getFileList() == null || adapterHuanjingzhaopian.getFileList().size() <= 0) {
                uploadImgHuanjingzhaopian = true;
            } else {
                for (File file : adapterHuanjingzhaopian.getFileList()) {
                    sendPhotoToServerHuanjingzhaopian(file.getPath());
                }
            }
        }
        enterpriseBind();
    }

    /**
     * 绑定企业
     */
    private void enterpriseBind() {
        //所有图片都上传完成后才执行绑定企业操作
        if (uploadImgShangchuandianzhao == true && uploadImgYingyezhizhao == true && uploadImgFangchanzheng == true && uploadImgFarenshenfenzheng == true && uploadImgHuanjingzhaopian == true) {
            //企业名称
            dataBean.name = etFarenQiyemingcheng.getText().toString().trim();
            //营业执照号码
            dataBean.license = etQiyeYingyezhizhaohaoma.getText().toString().trim();
            //法人姓名
            dataBean.legalname = etFarenFarenxingming.getText().toString().trim();
            //法人联系方式
            dataBean.legaltel = etFarenLianxifangshi.getText().toString().trim();
            //环保负责人
            dataBean.legalismaster = etFuzerenFuzerenxingming.getText().toString().trim();
            //环保负责人联系方式
            dataBean.mastertel = etFuzerenLianxifangshi.getText().toString().trim();
            //行业规模
            dataBean.scale = etHangyexinxiHangyeguimo.getText().toString().trim();

            Map<String, String> map = new HashMap<>();
            map.put("img", dataBean.img);//上传店招照片
            map.put("name", dataBean.name);//企业名称
            map.put("categoryid", dataBean.categoryid);//企业类型
            map.put("license", dataBean.license);//营业执照号码
            map.put("buildtime", dataBean.buildtime);//建设时间
            map.put("opentime", dataBean.opentime);//开业时间
            map.put("address", dataBean.address);//详细地址
            map.put("lat", dataBean.lat);//纬度
            map.put("lng", dataBean.lng);//经度
            map.put("licenseimg1", dataBean.licenseimg1);//营业执照 照片1和2
            map.put("licenseimg2", dataBean.licenseimg2);//营业执照 照片1和2
            map.put("licensetime", dataBean.licensetime);//营业执照 有效期至
            map.put("fangchanimg1", dataBean.fangchanimg1);//房产证照片1和2
            map.put("fangchanimg2", dataBean.fangchanimg2);//房产证照片1和2
            map.put("fangchantime", dataBean.fangchantime);//房产证 有效期至
            map.put("legalname", dataBean.legalname);//法人姓名
            map.put("legaltel", dataBean.legaltel);//法人联系方式
            map.put("legalcard1", dataBean.legalcard1);//法人身份证照片1和2
            map.put("legalcard2", dataBean.legalcard2);//法人身份证照片1和2
            map.put("legalcardtime", dataBean.legalcardtime);//法人身份证有效期至
            map.put("legalismaster", dataBean.legalismaster);//是否为环保负责人 0不是环保负责人、1是环保负责人
            map.put("mastername", dataBean.mastername);//环保负责人 姓名
            map.put("mastertel", dataBean.mastertel);//环保负责人 联系方式
            map.put("type", dataBean.type);//行业分类
            map.put("scale", dataBean.scale);//行业规模
            map.put("environimgs", dataBean.environimgs);//环境照片
            fromNetwork.enterpriseBind(map)
                    .compose(new RxActivityHelper<CommonReturn>().ioMain(GuanLianQiYeActivity.this, true))
                    .subscribe(new MySubscribe<CommonReturn>(mContext, true) {
                        @Override
                        protected void success(CommonReturn resultBean) {
                            //tangkun 发出通知 刷新企业管理列表
                            EventBus.getDefault().post(true, "QiYeGuanLiActivity.refresh");
                            showToast("提交成功");
                            Utils.hideSoftKeyboard(GuanLianQiYeActivity.this, back);
                            JumpHelper.finish(mContext);
                        }

                        @Override
                        protected void onMyError(String errorMessage) {
                            showToast(errorMessage);
                        }
                    });
        }
    }

    /**
     * 设置日期
     *
     * @param textView 控件
     */
    private void setDate(final TextView textView) {
        if (datePicker != null && datePicker.isShowing()) {
            datePicker.dismiss();
        } else {
            datePicker = new DatePicker(GuanLianQiYeActivity.this);
            //顶部高度
            datePicker.setTopHeight(47);
            //取消按钮颜色
            datePicker.setCancelTextColor(getResources().getColor(R.color.common_tips));
            //取消按钮文字大小
            datePicker.setCancelTextSize(17);
            //确认按钮颜色
            datePicker.setSubmitTextColor(getResources().getColor(R.color.common_green));
            //按下的文字颜色
            datePicker.setPressedTextColor(getResources().getColor(R.color.common_green_80));
            //确认按钮文字大小
            datePicker.setSubmitTextSize(17);
            //顶部标题栏下划线颜色
            datePicker.setTopLineColor(getResources().getColor(R.color.divider_color_80));
            //顶部标题栏下划线高度
            datePicker.setTopLineHeight(1);
            //日期上下分割线颜色
            datePicker.setLineColor(getResources().getColor(R.color.common_other));
            //日期颜色
            datePicker.setTextColor(getResources().getColor(R.color.common_word));
            //控件展示动画
            datePicker.setAnimationStyle(R.style.PopupwindowStyle);
            //年份范围
            datePicker.setRange(1900, 2100);
            //默认选择日期
            datePicker.setSelectedItem(Integer.valueOf(Utils.getCurrentDateYear()), Integer.valueOf(Utils.getCurrentDateMonth()), Integer.valueOf(Utils.getCurrentDateDay()));
            datePicker.setOnDatePickListener(new DatePicker.OnYearMonthDayPickListener() {
                @Override
                public void onDatePicked(String year, String month, String day) {
                    textView.setText(year + "-" + month + "-" + day);
                }
            });
            datePicker.show();
        }
    }

    /**
     * 打开相册 上传店招
     */
    private void openXiangceShangchuandianzhao() {
        Intent intent = new Intent(GuanLianQiYeActivity.this, CaptureImageActivity.class);
        intent.putExtra("w", IMAGE_W);
        intent.putExtra("h", IMAGE_H);
        intent.putExtra("custom", false);
        intent.putExtra("module", "weibo");
        intent.putExtra("num", IMAGE_NUM_SHANGCHUANDIANZHAO);
        intent.putExtra("isShowOriginal", false);
        startActivityForResult(intent, REQUEST_CODE_SHANGCHUANDIANZHAO);
    }

    /**
     * 打开相册 营业执照
     */
    private void openXiangceYingyezhizhao() {
        Intent intent = new Intent(GuanLianQiYeActivity.this, CaptureImageActivity.class);
        intent.putExtra("w", IMAGE_W);
        intent.putExtra("h", IMAGE_H);
        intent.putExtra("custom", false);
        intent.putExtra("module", "weibo");
        intent.putExtra("num", IMAGE_NUM_YINGYEZHIZHAO - adapterYingyezhizhao.getFileList().size());
        intent.putExtra("isShowOriginal", false);
        startActivityForResult(intent, REQUEST_CODE_YINGYEZHIZHAO);
    }

    /**
     * 打开相册 房产证
     */
    private void openXiangceFangchanzheng() {
        Intent intent = new Intent(GuanLianQiYeActivity.this, CaptureImageActivity.class);
        intent.putExtra("w", IMAGE_W);
        intent.putExtra("h", IMAGE_H);
        intent.putExtra("custom", false);
        intent.putExtra("module", "weibo");
        intent.putExtra("num", IMAGE_NUM_FANGCHANZHENG - adapterFangchanzheng.getFileList().size());
        intent.putExtra("isShowOriginal", false);
        startActivityForResult(intent, REQUEST_CODE_FANGCHANZHENG);
    }

    /**
     * 打开相册 法人身份证
     */
    private void openXiangceFarenshenfenzheng() {
        Intent intent = new Intent(GuanLianQiYeActivity.this, CaptureImageActivity.class);
        intent.putExtra("w", IMAGE_W);
        intent.putExtra("h", IMAGE_H);
        intent.putExtra("custom", false);
        intent.putExtra("module", "weibo");
        intent.putExtra("num", IMAGE_NUM_FARENSHENFENZHENG - adapterFarenshenfenzheng.getFileList().size());
        intent.putExtra("isShowOriginal", false);
        startActivityForResult(intent, REQUEST_CODE_FARENSHENFENZHENG);
    }

    /**
     * 打开相册 环境照片
     */
    private void openXiangceHuanjingzhaopian() {
        Intent intent = new Intent(GuanLianQiYeActivity.this, CaptureImageActivity.class);
        intent.putExtra("w", IMAGE_W);
        intent.putExtra("h", IMAGE_H);
        intent.putExtra("custom", false);
        intent.putExtra("module", "weibo");
        intent.putExtra("num", IMAGE_NUM_HUANJINGZHAOPIAN - adapterHuanjingzhaopian.getFileList().size());
        intent.putExtra("isShowOriginal", false);
        startActivityForResult(intent, REQUEST_CODE_HUANJINGZHAOPIAN);
    }


    /**
     * 上传图片到服务器 上传店招
     *
     * @param filePath 本地图片路径
     */
    private synchronized void sendPhotoToServerShangchuanDianzhao(String filePath) {
        String[] filePathArray = filePath.split("/");
        //文件名
        String fileName = filePathArray[filePathArray.length - 1];
        fileName = fileName + ".png";//加上.png后缀名
        LogUtils.e("文件名称：" + fileName);
        //生成文件
        File file = new File(filePath);
        //组装partMap对象
        Map<String, RequestBody> partMap = new HashMap<>();
        RequestBody fileBody = RequestBody.create(MediaType.parse("image/*"), file);//文件
        partMap.put("file\"; filename=\"" + fileName + "", fileBody);//文件名
        fromNetwork.uploadImageEplogo(partMap).compose(new RxActivityHelper<UploadResourceReturn>().ioMain(GuanLianQiYeActivity.this, true))
                .subscribe(new MySubscribe<UploadResourceReturn>(mContext, true) {
                    @Override
                    protected void success(UploadResourceReturn uploadResourceReturn) {
                        if (uploadResourceReturn.data != null) {
                            if (uploadResourceReturn.data.size() > 0) {
                                //文件上传成功，返回的图片半路径，拼接成图片集合
                                dataBean.img = uploadResourceReturn.data.get(0).url;
                                uploadImgShangchuandianzhao = true;
                                enterpriseBind();
                            }
                        }
                    }

                    @Override
                    protected void onMyError(String errorMessage) {
                        showToast(errorMessage);
                    }
                });
    }

    /**
     * 上传图片到服务器 营业执照
     *
     * @param filePath 本地图片路径
     */
    private synchronized void sendPhotoToServerYingyezhizhao(String filePath) {
        String[] filePathArray = filePath.split("/");
        //文件名
        String fileName = filePathArray[filePathArray.length - 1];
        fileName = fileName + ".png";//加上.png后缀名
        LogUtils.e("文件名称：" + fileName);
        //生成文件
        File file = new File(filePath);
        //组装partMap对象
        Map<String, RequestBody> partMap = new HashMap<>();
        RequestBody fileBody = RequestBody.create(MediaType.parse("image/*"), file);//文件
        partMap.put("file\"; filename=\"" + fileName + "", fileBody);//文件名
        fromNetwork.uploadImageEplicense(partMap).compose(new RxActivityHelper<UploadResourceReturn>().ioMain(GuanLianQiYeActivity.this, true))
                .subscribe(new MySubscribe<UploadResourceReturn>(mContext, true) {
                    @Override
                    protected void success(UploadResourceReturn uploadResourceReturn) {
                        if (uploadResourceReturn.data != null) {
                            if (uploadResourceReturn.data.size() > 0) {
                                //文件上传成功，返回的图片半路径，拼接成图片集合
                                if (TextUtils.isEmpty(imgYingyezhizhao)) {
                                    imgYingyezhizhao = uploadResourceReturn.data.get(0).url;
                                } else {
                                    imgYingyezhizhao = imgYingyezhizhao + "," + uploadResourceReturn.data.get(0).url;
                                }
                                //图片全部上传完成
                                if (imgYingyezhizhao.split(",").length == adapterYingyezhizhao.getFileList().size()) {
                                    uploadImgYingyezhizhao = true;
                                    dataBean.licenseimg1 = imgYingyezhizhao;
                                    enterpriseBind();
                                }
                            }
                        }
                    }

                    @Override
                    protected void onMyError(String errorMessage) {
                        showToast(errorMessage);
                    }
                });
    }

    /**
     * 上传图片到服务器 房产证
     *
     * @param filePath 本地图片路径
     */
    private synchronized void sendPhotoToServerFangChanZheng(String filePath) {
        String[] filePathArray = filePath.split("/");
        //文件名
        String fileName = filePathArray[filePathArray.length - 1];
        fileName = fileName + ".png";//加上.png后缀名
        LogUtils.e("文件名称：" + fileName);
        //生成文件
        File file = new File(filePath);
        //组装partMap对象
        Map<String, RequestBody> partMap = new HashMap<>();
        RequestBody fileBody = RequestBody.create(MediaType.parse("image/*"), file);//文件
        partMap.put("file\"; filename=\"" + fileName + "", fileBody);//文件名
        fromNetwork.uploadImageEpfangchan(partMap).compose(new RxActivityHelper<UploadResourceReturn>().ioMain(GuanLianQiYeActivity.this, true))
                .subscribe(new MySubscribe<UploadResourceReturn>(mContext, true) {
                    @Override
                    protected void success(UploadResourceReturn uploadResourceReturn) {
                        if (uploadResourceReturn.data != null) {
                            if (uploadResourceReturn.data.size() > 0) {
                                //文件上传成功，返回的图片半路径，拼接成图片集合
                                if (TextUtils.isEmpty(imgFangchanzheng)) {
                                    imgFangchanzheng = uploadResourceReturn.data.get(0).url;
                                } else {
                                    imgFangchanzheng = imgFangchanzheng + "," + uploadResourceReturn.data.get(0).url;
                                }
                                //图片全部上传完成
                                if (imgFangchanzheng.split(",").length == adapterFangchanzheng.getFileList().size()) {
                                    uploadImgFangchanzheng = true;
                                    dataBean.fangchanimg1 = imgFangchanzheng;
                                    enterpriseBind();
                                }
                            }
                        }
                    }

                    @Override
                    protected void onMyError(String errorMessage) {
                        showToast(errorMessage);
                    }
                });
    }

    /**
     * 上传图片到服务器 法人身份证
     *
     * @param filePath 本地图片路径
     */
    private synchronized void sendPhotoToServerFarenshenfenzheng(String filePath) {
        String[] filePathArray = filePath.split("/");
        //文件名
        String fileName = filePathArray[filePathArray.length - 1];
        fileName = fileName + ".png";//加上.png后缀名
        LogUtils.e("文件名称：" + fileName);
        //生成文件
        File file = new File(filePath);
        //组装partMap对象
        Map<String, RequestBody> partMap = new HashMap<>();
        RequestBody fileBody = RequestBody.create(MediaType.parse("image/*"), file);//文件
        partMap.put("file\"; filename=\"" + fileName + "", fileBody);//文件名
        fromNetwork.uploadImageEplegal(partMap).compose(new RxActivityHelper<UploadResourceReturn>().ioMain(GuanLianQiYeActivity.this, true))
                .subscribe(new MySubscribe<UploadResourceReturn>(mContext, true) {
                    @Override
                    protected void success(UploadResourceReturn uploadResourceReturn) {
                        if (uploadResourceReturn.data != null) {
                            if (uploadResourceReturn.data.size() > 0) {
                                //文件上传成功，返回的图片半路径，拼接成图片集合
                                if (TextUtils.isEmpty(imgFarenshenfenzheng)) {
                                    imgFarenshenfenzheng = uploadResourceReturn.data.get(0).url;
                                } else {
                                    imgFarenshenfenzheng = imgFarenshenfenzheng + "," + uploadResourceReturn.data.get(0).url;
                                }
                                //图片全部上传完成
                                if (imgFarenshenfenzheng.split(",").length == adapterFarenshenfenzheng.getFileList().size()) {
                                    uploadImgFarenshenfenzheng = true;
                                    dataBean.legalcard1 = imgFarenshenfenzheng;
                                    enterpriseBind();
                                }
                            }
                        }
                    }

                    @Override
                    protected void onMyError(String errorMessage) {
                        showToast(errorMessage);
                    }
                });
    }

    /**
     * 上传图片到服务器 环境照片
     *
     * @param filePath 本地图片路径
     */
    private synchronized void sendPhotoToServerHuanjingzhaopian(String filePath) {
        String[] filePathArray = filePath.split("/");
        //文件名
        String fileName = filePathArray[filePathArray.length - 1];
        fileName = fileName + ".png";//加上.png后缀名
        LogUtils.e("文件名称：" + fileName);
        //生成文件
        File file = new File(filePath);
        //组装partMap对象
        Map<String, RequestBody> partMap = new HashMap<>();
        RequestBody fileBody = RequestBody.create(MediaType.parse("image/*"), file);//文件
        partMap.put("file\"; filename=\"" + fileName + "", fileBody);//文件名
        fromNetwork.uploadImageEpenviron(partMap).compose(new RxActivityHelper<UploadResourceReturn>().ioMain(GuanLianQiYeActivity.this, true))
                .subscribe(new MySubscribe<UploadResourceReturn>(mContext, true) {
                    @Override
                    protected void success(UploadResourceReturn uploadResourceReturn) {
                        if (uploadResourceReturn.data != null) {
                            if (uploadResourceReturn.data.size() > 0) {
                                //文件上传成功，返回的图片半路径，拼接成图片集合
                                if (TextUtils.isEmpty(imgHuanjingzhaopian)) {
                                    imgHuanjingzhaopian = uploadResourceReturn.data.get(0).url;
                                } else {
                                    imgHuanjingzhaopian = imgHuanjingzhaopian + "," + uploadResourceReturn.data.get(0).url;
                                }
                                //图片全部上传完成
                                if (imgHuanjingzhaopian.split(",").length == adapterHuanjingzhaopian.getFileList().size()) {
                                    uploadImgHuanjingzhaopian = true;
                                    dataBean.environimgs = imgHuanjingzhaopian;
                                    enterpriseBind();
                                }
                            }
                        }
                    }

                    @Override
                    protected void onMyError(String errorMessage) {
                        showToast(errorMessage);
                    }
                });
    }

    @Override
    protected void onActivityResult(int requestCode, int resultCode, Intent data) {
        super.onActivityResult(requestCode, resultCode, data);
        //修改了企业类型
        if (requestCode == REQUEST_CODE_QIYELEIXING && resultCode == RESULT_OK) {
            //赋值选中企业类型ID
            dataBean.type = data.getStringExtra("id");
            String name = data.getStringExtra("name");
            //设置企业类型名称
            tvQiyeQiyeleixing.setText(TextUtils.isEmpty(name) ? "" : name);
        }

        //详细地址
        if (requestCode == REQUEST_CODE_XIANGXIDIZHI && resultCode == RESULT_OK) {
            latitude = data.getStringExtra("latitude");
            longitude = data.getStringExtra("longitude");
            address = data.getStringExtra("address");
            if (!TextUtils.isEmpty(address)) {
                tvQiyeXiangxidizhi.setText(address);
            } else {
                tvQiyeXiangxidizhi.setText("");
            }
            //赋值这三个变变量
            dataBean.address = address;
            dataBean.lat = latitude;
            dataBean.lng = longitude;
        }

        //修改了行业分类
        if (requestCode == REQUEST_CODE_HANGYEFENLEI && resultCode == RESULT_OK) {
            //赋值选中行业分类ID
            dataBean.categoryid = data.getStringExtra("id");
            String name = data.getStringExtra("name");
            //设置企业类型名称
            tvHangyexinxiHangyefenlei.setText(TextUtils.isEmpty(name) ? "" : name);
        }

        // 刷新来自相册列表选中的图片列表 上传店招
        if (requestCode == REQUEST_CODE_SHANGCHUANDIANZHAO && resultCode == CaptureImageActivity.CAPTURE) {
            List<File> list = (List<File>) data.getSerializableExtra("fileList");
            if (list != null) {
                fileListShangchuandianzhao.clear();
                fileListShangchuandianzhao.addAll(list);
                if (fileListShangchuandianzhao != null && fileListShangchuandianzhao.size() > 0) {
                    //上传店招
                    Glide.with(GuanLianQiYeActivity.this)
                            .load(fileListShangchuandianzhao.get(0).getPath())
                            .bitmapTransform(new CropCircleTransformation(GuanLianQiYeActivity.this))
                            .placeholder(R.mipmap.ic_guanlianqiye_shangchuandianzhao)
                            .dontAnimate()
                            .into(ivQiyeShangchuandianzhao);
                }
            }
        }

        // 刷新来自相册列表选中的图片列表 营业执照
        if (requestCode == REQUEST_CODE_YINGYEZHIZHAO && resultCode == CaptureImageActivity.CAPTURE) {
            List<File> list = (List<File>) data.getSerializableExtra("fileList");
            if (list != null) {
                adapterYingyezhizhao.getFileList().addAll(list);
                adapterYingyezhizhao.notifyDataSetChanged();
                Utils.setGridViewHeightBasedOnChildren(mygridviewYingyezhizhao, 7);
                if (adapterYingyezhizhao.getFileList() != null && adapterYingyezhizhao.getFileList().size() > 0) {
                    mygridviewYingyezhizhao.setVisibility(View.VISIBLE);
                } else {
                    mygridviewYingyezhizhao.setVisibility(View.GONE);
                }
            }
        }
        // 刷新有过删除后的图片列表 营业执照
        if (requestCode == REQUEST_CODE_YINGYEZHIZHAO && resultCode == DeleteImageActivity.RESULT_CODE_DELETE_CHANGED) {
            List<File> fileList = new ArrayList<File>();
            fileList = (List<File>) data.getSerializableExtra("fileList");
            if (fileList != null) {
                adapterYingyezhizhao.setFileList(fileList);
            }
            Utils.setGridViewHeightBasedOnChildren(mygridviewYingyezhizhao, 7);
            adapterYingyezhizhao.notifyDataSetChanged();
            if (adapterYingyezhizhao.getFileList() != null && adapterYingyezhizhao.getFileList().size() > 0) {
                mygridviewYingyezhizhao.setVisibility(View.VISIBLE);
            } else {
                mygridviewYingyezhizhao.setVisibility(View.GONE);
            }
        }

        // 刷新来自相册列表选中的图片列表 房产证
        if (requestCode == REQUEST_CODE_FANGCHANZHENG && resultCode == CaptureImageActivity.CAPTURE) {
            List<File> list = (List<File>) data.getSerializableExtra("fileList");
            if (list != null) {
                adapterFangchanzheng.getFileList().addAll(list);
                adapterFangchanzheng.notifyDataSetChanged();
                Utils.setGridViewHeightBasedOnChildren(mygridviewFangchanzheng, 7);
                if (adapterFangchanzheng.getFileList() != null && adapterFangchanzheng.getFileList().size() > 0) {
                    mygridviewFangchanzheng.setVisibility(View.VISIBLE);
                } else {
                    mygridviewFangchanzheng.setVisibility(View.GONE);
                }
            }
        }
        // 刷新有过删除后的图片列表 房产证
        if (requestCode == REQUEST_CODE_FANGCHANZHENG && resultCode == DeleteImageActivity.RESULT_CODE_DELETE_CHANGED) {
            List<File> fileList = new ArrayList<File>();
            fileList = (List<File>) data.getSerializableExtra("fileList");
            if (fileList != null) {
                adapterFangchanzheng.setFileList(fileList);
            }
            Utils.setGridViewHeightBasedOnChildren(mygridviewFangchanzheng, 7);
            adapterFangchanzheng.notifyDataSetChanged();
            if (adapterFangchanzheng.getFileList() != null && adapterFangchanzheng.getFileList().size() > 0) {
                mygridviewFangchanzheng.setVisibility(View.VISIBLE);
            } else {
                mygridviewFangchanzheng.setVisibility(View.GONE);
            }
        }

        // 刷新来自相册列表选中的图片列表 法人身份证
        if (requestCode == REQUEST_CODE_FARENSHENFENZHENG && resultCode == CaptureImageActivity.CAPTURE) {
            List<File> list = (List<File>) data.getSerializableExtra("fileList");
            if (list != null) {
                adapterFarenshenfenzheng.getFileList().addAll(list);
                adapterFarenshenfenzheng.notifyDataSetChanged();
                Utils.setGridViewHeightBasedOnChildren(mygridviewFanrenshenfenzheng, 7);
                if (adapterFarenshenfenzheng.getFileList() != null && adapterFarenshenfenzheng.getFileList().size() > 0) {
                    mygridviewFanrenshenfenzheng.setVisibility(View.VISIBLE);
                } else {
                    mygridviewFanrenshenfenzheng.setVisibility(View.GONE);
                }
            }
        }
        // 刷新有过删除后的图片列表 法人身份证
        if (requestCode == REQUEST_CODE_FARENSHENFENZHENG && resultCode == DeleteImageActivity.RESULT_CODE_DELETE_CHANGED) {
            List<File> fileList = new ArrayList<File>();
            fileList = (List<File>) data.getSerializableExtra("fileList");
            if (fileList != null) {
                adapterFarenshenfenzheng.setFileList(fileList);
            }
            Utils.setGridViewHeightBasedOnChildren(mygridviewFanrenshenfenzheng, 7);
            adapterFarenshenfenzheng.notifyDataSetChanged();
            if (adapterFarenshenfenzheng.getFileList() != null && adapterFarenshenfenzheng.getFileList().size() > 0) {
                mygridviewFanrenshenfenzheng.setVisibility(View.VISIBLE);
            } else {
                mygridviewFanrenshenfenzheng.setVisibility(View.GONE);
            }
        }

        // 刷新来自相册列表选中的图片列表 环境照片
        if (requestCode == REQUEST_CODE_HUANJINGZHAOPIAN && resultCode == CaptureImageActivity.CAPTURE) {
            List<File> list = (List<File>) data.getSerializableExtra("fileList");
            if (list != null) {
                adapterHuanjingzhaopian.getFileList().addAll(list);
                adapterHuanjingzhaopian.notifyDataSetChanged();
                Utils.setGridViewHeightBasedOnChildren(mygridviewTianjiahuanjingzhaopian, 7);
                if (adapterHuanjingzhaopian.getFileList() != null && adapterHuanjingzhaopian.getFileList().size() > 0) {
                    mygridviewTianjiahuanjingzhaopian.setVisibility(View.VISIBLE);
                } else {
                    mygridviewTianjiahuanjingzhaopian.setVisibility(View.GONE);
                }
            }
        }
        // 刷新有过删除后的图片列表 环境照片
        if (requestCode == REQUEST_CODE_HUANJINGZHAOPIAN && resultCode == DeleteImageActivity.RESULT_CODE_DELETE_CHANGED) {
            List<File> fileList = new ArrayList<File>();
            fileList = (List<File>) data.getSerializableExtra("fileList");
            if (fileList != null) {
                adapterHuanjingzhaopian.setFileList(fileList);
            }
            Utils.setGridViewHeightBasedOnChildren(mygridviewTianjiahuanjingzhaopian, 7);
            adapterHuanjingzhaopian.notifyDataSetChanged();
            if (adapterHuanjingzhaopian.getFileList() != null && adapterHuanjingzhaopian.getFileList().size() > 0) {
                mygridviewTianjiahuanjingzhaopian.setVisibility(View.VISIBLE);
            } else {
                mygridviewTianjiahuanjingzhaopian.setVisibility(View.GONE);
            }
        }
    }
}
